<?php
/*
 * mk script created on 14-mag-2005
 * jaco_at_pixeldump_dot_org
 * mixed techniques
 */

include("sample_utils.php");                            // provides some utils and using mk

$swf = new MKSwf("test_nuke.swf");                       // start a fresh swf
$swf->set_swfDir(SERVER_MKTMP);                          // change default working dir

$img01 = "tile01.png";                                   // list of image to load
$img02 = "tile02.png";                                   //
$img03 = "tile03.png";                                   //
$img04 = "cave01.png";                                   //
$img05 = "nuke01.png";                                   //

$bm = new BitmapItem();                                 // mk bitmap item class

$bmTag = $bm->create_from_file($img01);                  // create swf tag from file
$img01Width = $bm->get_bitmapWidth();                    //
$img01Height = $bm->get_bitmapHeight();                  // width, height of image
$swf->add_tagData($bmTag);                               // populate swf with imge data

$bm->set_bitmapID(2);                                    // from second image and on we need to set ID
$bmTag = $bm->create_from_file($img02);                  // create swf tag from file
$img02Width = $bm->get_bitmapWidth();                    //
$img02Height = $bm->get_bitmapHeight();                  // width, height of image
$swf->add_tagData($bmTag);                               // populate swf with imge data

$bm->set_bitmapID(3);
$bmTag = $bm->create_from_file($img03);                  // create swf tag from file
$img03Width = $bm->get_bitmapWidth();                    //
$img03Height = $bm->get_bitmapHeight();                  // width, height of image
$swf->add_tagData($bmTag);                               // populate swf with imge data

$bm->set_bitmapID(4);
$bmTag = $bm->create_from_file($img04);                  // create swf tag from file
$img04Width = $bm->get_bitmapWidth();                    //
$img04Height = $bm->get_bitmapHeight();                  // width, height of image
$swf->add_tagData($bmTag);                               // populate swf with imge data

$bm->set_bitmapID(5);
$bmTag = $bm->create_from_file($img05);                  // create swf tag from file
$img05Width = $bm->get_bitmapWidth();                    //
$img05Height = $bm->get_bitmapHeight();                  // width, height of image
$swf->add_tagData($bmTag);                               // populate swf with imge data

$sc = new MKShapeContainer("", 6);                      // the shape that will wrap bitmaps

// add bitmap fills
// for a single bounded image use CLIPPED_BITMAP_FILL
// for tiled images use REPEATING_BITMAP_FILL
// the last parameter [matrixBitmap] will place the bitmap in the right position
$sc->add_bitmap_fill(1, REPEATING_BITMAP_FILL);
$sc->add_rect(0, 0, 550, 290);                           // image bounding box

$mad = array();							                 // this ...
$mad["x"] = 0;						                     // ... array is used ...
$mad["y"] = 290;							             // ... to place bitmap
$mad["width"] = 640;			                         // ... properly
$mad["height"] = $img02Height;			                 //
$sc->add_bitmap_fill(2, REPEATING_BITMAP_FILL, $mad);
$sc->add_rect(0, 290, 550, $img02Height);                // image bounding box

$mad["x"] = 0;						                     // ... array is used ...
$mad["y"] = 290 + $img02Height;							 // ... to place bitmap
$mad["width"] = 640;			                         // ... correctly
$mad["height"] = $img03Height;			                 //
$sc->add_bitmap_fill(3, REPEATING_BITMAP_FILL, $mad);
$sc->add_rect(0, 290 + $img02Height, 550, $img03Height); // image bounding box

$sc->increase_shapeDepth();
$mad["x"] = 150;						                 // ... array is used ...
$mad["y"] = 156;							             // ... to place bitmap
$mad["width"] = $img04Width;			                 // ... correctly
$mad["height"] = $img04Height;			                 //
$sc->add_bitmap_fill(4, CLIPPED_BITMAP_FILL, $mad);
$sc->add_rect(150, 156, $img04Width, $img04Height);      // image bounding box

$sc->increase_shapeDepth();
$mad["x"] = 230;						                 // ... array is used ...
$mad["y"] = 208;							             // ... to place bitmap
$mad["width"] = $img05Width;			                 // ... correctly
$mad["height"] = $img05Height;			                 //
$sc->add_bitmap_fill(5, CLIPPED_BITMAP_FILL, $mad);
$sc->add_rect(230, 208, $img05Width, $img05Height);      // image bounding box

$shapeTD = $sc->update_tagData();				         // get shape tag
$shapePB = $sc->update_place_tagData();

$svg01 = new MKSimpleSvgReader("nuke_txt.svg");        // get vector lettering data
$svg01->set_itemID(7);
$svgTD = $svg01->update_TagData();
$svgPB = $svg01->update_place_tagData();

$swf->add_tagData($shapeTD);                             // populate with shape
$swf->add_tagData($svgTD);                               // populate with shape
$swf->add_tagData($shapePB);                             // place on stage
$swf->add_tagData($svgPB);                               // place on stage
$swf->set_isCompressed("yes");                           // gain some extra byte
$swf->swf_output();                                      // save to disk

$swfHeader = $swf->fetch_assoc();                        // prepare to publish

$str = render_swf_box($swfHeader, $imgDir, false);
$str .= "<br/><strong>test_nuke.swf created in " .SERVER_MKTMP ."</strong>";
echo show_content($str, basename(__FILE__));
?>
